package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.CriterionDefDao;
import cn.topevery.garden.entity.po.CriterionDef;
import cn.topevery.garden.entity.query.CriterionDefQuery;
import cn.topevery.garden.entity.vo.CriterionDefVO;
import cn.topevery.garden.entity.vo.CriterionTableVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 综合评价标准定义表
 *
 * @author code-generate
 * @date 2022-01-05
 */
@Service
public class CriterionDefLogic extends BaseLogic<CriterionDef> {
    @Autowired
    CriterionDefDao criterionDefDao;

    @Override
    public BaseEntityDao<CriterionDef, Integer> getDao() {
        return criterionDefDao;
    }



    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<CriterionDefVO> listPage(CriterionDefQuery query) {
        return criterionDefDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        criterionDefDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param criterionDef 实体
     */
    public void saveOrUpdate(String userId, CriterionDef criterionDef){
        criterionDefDao.saveOrUpdate(userId,criterionDef);
    }

    /**
         * 根据自定义列值来获取对象
         */
    public CriterionDef getEntityByColumn(String key, String value) {
        return criterionDefDao.getEntityByColumn(key, value);
    }

    public List<CriterionDef> getListByPid(String pid) {
        return criterionDefDao.getListByPid(pid);
    };

    public List<CriterionDef> getListByPidIgnoreRelation(String pid) {
        return criterionDefDao.getListByPidIgnoreRelation(pid);
    };

    public List<CriterionDef> getRootListByCriterionId(String rootId) {
        return criterionDefDao.getRootListByCriterionId(rootId);
    };

    public void insert(List<CriterionDef> criterionList, Integer userId) {
        criterionDefDao.insert(criterionList, userId);
    };

    public List<CriterionDef> getById(String criterionId) {
        return criterionDefDao.getById(criterionId);
    };

    public void update(List<CriterionDef> criterionList, Integer userId) {
        criterionDefDao.update(criterionList, userId);
    };

    public void delete(String criterionId, Integer userId) {
        criterionDefDao.delete(criterionId, userId);
    };

    public CriterionDef getRelationById(String criterionId) {
        return criterionDefDao.getRelationById(criterionId);
    };

    public CriterionDef getOneById(String criterionId) {
        return criterionDefDao.getOneById(criterionId);
    };

    public List<Map<String, Object>> getCountList(String year, Integer type) {
        return type == 0 ? criterionDefDao.getCountList(year) : criterionDefDao.getCountShowList(year);

    };

    public List<CriterionTableVO> getCriterionTableByMapIdAndYear(Map<String, String> map, Integer isReach, Integer isShow) {
        return criterionDefDao.getCriterionTableByMapIdAndYear(map, isReach, isShow);
    };

    public List<Map<String, Object>> getHomeInfo(String mapId) {
        return criterionDefDao.getHomeInfo(mapId);
    };

    public List<Map<String, Object>> getHomeInfoShow(String mapId) {
        return criterionDefDao.getHomeInfoShow(mapId);
    }

}
